<?php /*Added by suwondo*/ ?>
<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"JS-6");
$currentPage = $_SERVER["PHP_SELF"];
mysql_select_db($database_con_gl, $con_gl);
$bid = $_GET['barang'];
$area = $_GET['area'];
echo $area;
list($namaarea) = mysql_fetch_row(mysql_query("select area from gl_area where id = '$area'"));
?>
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<h1>Data Tipe Kendaraan <?php if($area != '') echo "Area ".$namaarea;?></h1>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
	<tr valign="top" bgcolor="#FFFFFF" class="hide">
        <td colspan="11" align="right" style="border-bottom:solid 1px #E2EAC1;border-right:solid 1px #E2EAC1;">
			<form id="search" name="search" method="post" action="">
			<!-- Edit by suwondo -->
			  Pencarian data : 
				<label>
					<input name="cr_txt" type="text" id="cr_txt" placeholder="Find by: tipe kendaraan" onclick="this.select(); $(this).autocomplete('components/kendaraan/search.autocomplete.php?barang=<?php echo $bid; ?>&area=<?php echo $area; ?>', { width: 330 });" size="45" maxlength="100" onkeyup="javascript: $(this).autocomplete('components/kendaraan/search.autocomplete.php?barang=<?php echo $bid; ?>&area=<?php echo $area; ?>', { width: 330 }); $(this).result(function(event, data, formatted){ idx = formatted.split(' - '); window.location.href='index.php?component=kendaraan&task=list&barang=<?php echo $bid; ?>&area=<?php echo $area; ?>&open=window&cr_kel=ALL&cr_txt='+idx[1]; });" <?php echo $_REQUEST['cr_txt'];?> />
				</label>
				<label><input name="Search" type="submit" id="Search" value="Search" /></label>
			</form>
		<?php
		if(isset($_POST['Search'])) {
			echo "<script>window.location=\"index.php?component=kendaraan&task=list&barang=$bid&area=$area&open=window&cr_kel=ALL&cr_txt=".str_replace(" ","+",$_POST[cr_txt])."\";</script>";
		}
		?>		</td>
	</tr>
	<tr>
		<th width="500"><strong>Tipe Kendaraan</strong></th>
		<th width="219"><strong>Tahun</strong></th>
		<th width="219"><strong>No. Polisi</strong></th>
		<th width="119"><strong>Area</strong></th>
		<th width="119"><strong>Cabang</strong></th>
		<th width="132" align="center" class="hide"><strong>Aksi</strong></th>
	</tr>
	<?php
	$key = trim($_REQUEST['cr_txt']);
	if($bid == 'false'){
		echo $query = mysql_query("select a.id, a.tipekendaraan, b.tahun, b.nopolisi, b.area, b.cabang from gl_tipekendaraan as a inner join gl_masterkendaraan as b on (a.id = b.tipekendaraan) where b.tersedia='1' and a.tipekendaraan like '%$key%' or b.nopolisi like '%$key%' order by b.nopolisi asc") or die (mysql_error()); 
	}else{ 
		$query = mysql_query("select a.id, a.tipekendaraan, b.tahun, b.nopolisi, b.area, b.cabang from gl_tipekendaraan as a inner join gl_masterkendaraan as b on (a.id = b.tipekendaraan) inner join gl_jenbar as c on (a.id = c.jenis) where c.barang='$bid' AND b.area = '$area' and b.nopolisi like '%$key%' order by a.tipekendaraan asc") or die (mysql_error()); 
		} 
		while(list($id, $tipe, $tahun, $nopolisi, $area, $cabang) = mysql_fetch_row($query)){
		echo "<tr>";
		list($namaarea) = mysql_fetch_row(mysql_query("select area from gl_area where id='$area'"));
		list($namagudang) = mysql_fetch_row(mysql_query("select gudang from gl_gudang where id='$cabang'"));
		echo "<td>$tipe</td><td>$tahun</td><td>$nopolisi</td><td>$namaarea</td><td>$namagudang</td><td align='center'><input type='button' value='pilih' onclick=\"javascript: window.opener.document.getElementById('kendaraan').value='$nopolisi'; window.opener.document.getElementById('txtkendaraan').value='$tipe ($nopolisi)';"; 
		if($bid !== 'false'){
		echo " window.opener.getHargaKendaraan(); window.opener.getBiayaBBM(); window.opener.getBiayaTol(); window.opener.getBiayaParkir(); window.opener.getBiayaSupir(); window.opener.getBiayaAkomodasi(); window.opener.getBiayaOther(); window.opener.getTotal(); window.opener.getGrandTotal(); ";
		}
		echo "window.close(1000);\" /></td>";
		echo "</tr>";
	}
	?>
 </table>
